package cn.z2huo.algorithm.stack.numberSystemsConversion;

import java.util.Deque;
import java.util.LinkedList;

/**
 * 数制转换
 * 作者：张一卓
 * 创建日期：2020/10/10
 */
public class NumberSystemsConversion {
    public static final int OCTONARY = 8;
    public static final int DECIMALISM = 10;
    public static final int BINARY = 2;

    public static void main(String[] args) {
        convertNumberSystem(1348, OCTONARY);
        convertNumberSystem(1348, BINARY);
        convertNumberSystem(1348, DECIMALISM);
    }

    public static void convertNumberSystem(long number, int convertNumber){
        Deque<Long> stack = new LinkedList<>();
        while (number != 0){
            stack.push(number % convertNumber);
            number = number / convertNumber;
        }
        stack.forEach(System.out::print);
        System.out.println();
    }
}
